import { Component, inject, OnInit } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzDividerModule } from 'ng-zorro-antd/divider';
import { NzFormModule } from 'ng-zorro-antd/form';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzInputModule } from 'ng-zorro-antd/input';
import { NzSelectModule } from 'ng-zorro-antd/select';
import { NzSpaceModule } from 'ng-zorro-antd/space';
import { NzTableModule } from 'ng-zorro-antd/table';
import { DeptService } from './dept.service';
import { CommonModule } from '@angular/common';
import { NzTreeSelectModule } from 'ng-zorro-antd/tree-select';
import { NzModalModule } from 'ng-zorro-antd/modal';
import { NzRadioModule } from 'ng-zorro-antd/radio';
// import { handleTree } from '../../../../utils/ruoyi';

@Component({
  selector: 'app-dept',
  imports: [
    NzInputModule,
    ReactiveFormsModule,
    NzButtonModule,
    NzFormModule,
    NzSelectModule,
    NzTableModule,
    NzDividerModule,
    NzIconModule,
    NzSpaceModule,
    CommonModule,
    NzTreeSelectModule,
    NzModalModule,
    NzRadioModule
  ],
  templateUrl: './dept.component.html',
  styleUrl: './dept.component.scss'
})
export class DeptComponent implements OnInit  {
  deptData: any[] = [];
  loading: boolean = false;
  deptName: string = '';
  deptParent: string = '';
  deptStatus: string = '';
  total: number = 0;
  pageIndex: number = 1;
  pageSize: number = 10;

  private readonly deptSvc = inject(DeptService);

  ngOnInit(): void { 
    this.loadDepsts();
  }

  loadDepsts() {
    // 模拟数据
    this.deptSvc.getDepts().subscribe(res => {      
      // this.deptData = handleTree(res.data);
      this.deptData = res.data;
    });
  }
  
}
